$(function() {
	//商品分类树形结构，注意，标签必须为  class="easyui-textbox" id="goodsCategory"
	$.post("${basePath}/category/getlist", function(data) {
		
		var menulist = [];
		if(a){
		menulist.push({
			id: '',
			text: '全部',
			parent_id: '0',
			iconCls: ''
		});	
		}
		$.each(data, function(i, item) {
			menulist.push({
				id: item.categoryid,
				text: item.categoryname,
				parent_id: item.parentid,
				iconCls: item.icon
			});
		});
		

		
		
		for(var i = 0; i < menulist.length; i++) {
			var children = menulist[i].children || [];
			for(var j = 0; j < menulist.length; j++) {
				if(menulist[j].parent_id == menulist[i].id) {
					children.push(menulist[j]);
				}
			}
			menulist[i].children = children;
		}
		var treeData = [];
		if(f){
			treeData = [{id:"0", text:'无', iconCls:'glyphicon-asterisk'}];
		}else{
			if($("#modifyFlag").length == 0){
				$('#goodsCategory').val(menulist[0].id);
			}
		}
		$.each(menulist, function(i, item) {
			if(item.parent_id == 0) {
				treeData.push(item);
			}
		});
		$("#goodsCategory").combotree({
			data: treeData,
			onClick: function(node) {
				if (!$(this).tree('isLeaf', node.target)) {
					$('#goodsCategory').combo('showPanel');
				}
			}
		});
	});
});
